import { createRouter, createWebHistory } from 'vue-router'

// 导入页面组件
const Home = () => import('../views/Home.vue')
const Streams = () => import('../views/Streams.vue')
const Clients = () => import('../views/Clients.vue')
const DVR = () => import('../views/DVR.vue')
const About = () => import('../views/About.vue')

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: {
      title: '首页 - SRS管理控制台'
    }
  },
  {
    path: '/streams',
    name: 'Streams',
    component: Streams,
    meta: {
      title: '直播流管理 - SRS管理控制台'
    }
  },
  {
    path: '/clients',
    name: 'Clients',
    component: Clients,
    meta: {
      title: '客户端管理 - SRS管理控制台'
    }
  },
  {
    path: '/about',
    name: 'About',
    component: About,
    meta: {
      title: '关于 - SRS管理控制台'
    }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

// 路由前置守卫
router.beforeEach((to, from, next) => {
  // 设置页面标题
  document.title = to.meta.title || 'SRS管理控制台'
  next()
})

export default router